package cn.amossun.starter.event.handler;

import cn.amossun.starter.event.EventDefinition;
import cn.amossun.starter.event.property.EventMessage;
import cn.amossun.starter.event.property.SimpleEventMessage;

import java.util.Map;

public interface RemoteEventMessagePublisher<E extends EventMessage> extends EventMessagePublisher {

    default SimpleEventMessage eventMessage(String service, String instance,
                                              String topic, EventDefinition.Scope definition,
                                              String description, String methodName,
                                              String message, Map<String, Object> argumentsMap) {
        SimpleEventMessage eventMessage = new SimpleEventMessage();
        eventMessage.setService(service);
        eventMessage.setInstance(instance);
        eventMessage.setTopic(topic);
        eventMessage.setDefinition(definition.getCode());
        eventMessage.setDescription(description);
        eventMessage.setMethodName(methodName);
        eventMessage.setMessage(message);
        eventMessage.setArgumentsMap(argumentsMap);
        return eventMessage;
    }

    /**
     * 推送远程事件
     *
     * @param exchangeName
     * @param routingKey
     * @param event 事件信息
     */
    void pushRemoteEvent(String exchangeName, String routingKey, E event);

}
